\hypertarget{event__handler_8c}{
\section{front\_\-panel/event\_\-handler.c File Reference}
\label{event__handler_8c}\index{front\_\-panel/event\_\-handler.c@{front\_\-panel/event\_\-handler.c}}
}
Event handler of various things.  


{\tt \#include $<$stdio.h$>$}\par
{\tt \#include $<$stdlib.h$>$}\par
{\tt \#include $<$avr/io.h$>$}\par
{\tt \#include $<$avr/interrupt.h$>$}\par
{\tt \#include $<$string.h$>$}\par
{\tt \#include \char`\"{}event\_\-handler.h\char`\"{}}\par
{\tt \#include \char`\"{}main.h\char`\"{}}\par
{\tt \#include \char`\"{}board.h\char`\"{}}\par
{\tt \#include \char`\"{}display.h\char`\"{}}\par
{\tt \#include \char`\"{}glcd.h\char`\"{}}\par
{\tt \#include \char`\"{}led\_\-control.h\char`\"{}}\par
{\tt \#include \char`\"{}../delay.h\char`\"{}}\par
{\tt \#include \char`\"{}../i2c.h\char`\"{}}\par
{\tt \#include \char`\"{}../global.h\char`\"{}}\par
{\tt \#include \char`\"{}band\_\-ctrl.h\char`\"{}}\par
{\tt \#include \char`\"{}antenna\_\-ctrl.h\char`\"{}}\par
{\tt \#include \char`\"{}remote\_\-control.h\char`\"{}}\par
{\tt \#include \char`\"{}eeprom\_\-m24.h\char`\"{}}\par
{\tt \#include \char`\"{}rotary\_\-encoder.h\char`\"{}}\par
{\tt \#include \char`\"{}menu.h\char`\"{}}\par
{\tt \#include \char`\"{}radio\_\-interface.h\char`\"{}}\par
{\tt \#include \char`\"{}sequencer.h\char`\"{}}\par
{\tt \#include \char`\"{}interrupt\_\-handler.h\char`\"{}}\par
{\tt \#include \char`\"{}../internal\_\-comm.h\char`\"{}}\par
{\tt \#include \char`\"{}errors.h\char`\"{}}\par
{\tt \#include \char`\"{}sub\_\-menu.h\char`\"{}}\par
\subsection*{Functions}
\begin{CompactItemize}
\item 
void \hyperlink{event__handler_8c_632e5b342e5ac553e16febfe66be431d}{event\_\-set\_\-error} (unsigned char error\_\-type, unsigned char state)
\begin{CompactList}\small\item\em Set that an error has occured. \item\end{CompactList}\item 
\hypertarget{event__handler_8c_aefc9239bce459297733216904acbe85}{
unsigned char \hyperlink{event__handler_8c_aefc9239bce459297733216904acbe85}{event\_\-get\_\-errors} (void)}
\label{event__handler_8c_aefc9239bce459297733216904acbe85}

\begin{CompactList}\small\item\em Retrieve the state error flags. \item\end{CompactList}\item 
unsigned char \hyperlink{event__handler_8c_ae1c682f593e5e0e43093e9bf9391871}{event\_\-get\_\-error\_\-state} (unsigned char error\_\-type)
\begin{CompactList}\small\item\em Retrieve the state of a specific error type. \item\end{CompactList}\item 
void \hyperlink{event__handler_8c_32acf4e703c1e015c422014d22976b9f}{event\_\-internal\_\-comm\_\-parse\_\-message} (\hyperlink{structUC__MESSAGE}{UC\_\-MESSAGE} message)
\begin{CompactList}\small\item\em Function which will parse the internal communication message. \item\end{CompactList}\item 
void \_\-\_\-inline\_\-\_\- \hyperlink{event__handler_8c_a505034c27af0141e92295c18cc89a0f}{event\_\-set\_\-rx\_\-antenna} (unsigned char ant\_\-index)
\begin{CompactList}\small\item\em Set an RX antenna. Will set the proper flags and call the antenna\_\-ctrl\_\-change\_\-rx\_\-ant function. \item\end{CompactList}\item 
void \hyperlink{event__handler_8c_b842189487606c37f6dfecff12714f6b}{event\_\-handler\_\-process\_\-ps2} (unsigned char key\_\-code)
\begin{CompactList}\small\item\em Process an PS2 event. \item\end{CompactList}\item 
\hypertarget{event__handler_8c_a8857be72780f3261f81a9a3ebf0d8aa}{
void \hyperlink{event__handler_8c_a8857be72780f3261f81a9a3ebf0d8aa}{event\_\-pulse\_\-sensor\_\-up} (void)}
\label{event__handler_8c_a8857be72780f3261f81a9a3ebf0d8aa}

\begin{CompactList}\small\item\em The pulse sensor was turned up. \item\end{CompactList}\item 
\hypertarget{event__handler_8c_b9a00ca4749b502864c535afc6f1f5a0}{
void \hyperlink{event__handler_8c_b9a00ca4749b502864c535afc6f1f5a0}{event\_\-pulse\_\-sensor\_\-down} (void)}
\label{event__handler_8c_b9a00ca4749b502864c535afc6f1f5a0}

\begin{CompactList}\small\item\em The pulse sensor was turned down. \item\end{CompactList}\item 
\hypertarget{event__handler_8c_c6178284e4debda791894aa3df3c9e82}{
void \hyperlink{event__handler_8c_c6178284e4debda791894aa3df3c9e82}{event\_\-update\_\-display} (void)}
\label{event__handler_8c_c6178284e4debda791894aa3df3c9e82}

\begin{CompactList}\small\item\em Function to be called if we wish to update the display. \item\end{CompactList}\item 
\hypertarget{event__handler_8c_5bc6c77effa965993a69575d51ceb87b}{
void \hyperlink{event__handler_8c_5bc6c77effa965993a69575d51ceb87b}{event\_\-poll\_\-buttons} (void)}
\label{event__handler_8c_5bc6c77effa965993a69575d51ceb87b}

\begin{CompactList}\small\item\em Function which will poll all buttons and perform the proper action depending on their state. \item\end{CompactList}\item 
\hypertarget{event__handler_8c_2622900ad0ca1e8d1d47a5d9d00ef86d}{
void \hyperlink{event__handler_8c_2622900ad0ca1e8d1d47a5d9d00ef86d}{event\_\-poll\_\-ext\_\-device} (void)}
\label{event__handler_8c_2622900ad0ca1e8d1d47a5d9d00ef86d}

\begin{CompactList}\small\item\em Function which will poll the external devices and perform the proper actions depending on their state. \item\end{CompactList}\item 
\hypertarget{event__handler_8c_6ded1fef0ab85bdcd464a3f53bd84c6f}{
void \hyperlink{event__handler_8c_6ded1fef0ab85bdcd464a3f53bd84c6f}{event\_\-tx\_\-button1\_\-pressed} (void)}
\label{event__handler_8c_6ded1fef0ab85bdcd464a3f53bd84c6f}

\begin{CompactList}\small\item\em Perform the action of TX antenna button 1 if it was pressed. \item\end{CompactList}\item 
\hypertarget{event__handler_8c_44c1527b187d3e8fd723bf6aa84f8333}{
void \hyperlink{event__handler_8c_44c1527b187d3e8fd723bf6aa84f8333}{event\_\-tx\_\-button2\_\-pressed} (void)}
\label{event__handler_8c_44c1527b187d3e8fd723bf6aa84f8333}

\begin{CompactList}\small\item\em Perform the action of TX antenna button 2 if it was pressed. \item\end{CompactList}\item 
\hypertarget{event__handler_8c_dcd46584264f5e558f7159954f062297}{
void \hyperlink{event__handler_8c_dcd46584264f5e558f7159954f062297}{event\_\-tx\_\-button3\_\-pressed} (void)}
\label{event__handler_8c_dcd46584264f5e558f7159954f062297}

\begin{CompactList}\small\item\em Perform the action of TX antenna button 3 if it was pressed. \item\end{CompactList}\item 
\hypertarget{event__handler_8c_c37acb56cc859cea8e655a8bbcf36250}{
void \hyperlink{event__handler_8c_c37acb56cc859cea8e655a8bbcf36250}{event\_\-tx\_\-button4\_\-pressed} (void)}
\label{event__handler_8c_c37acb56cc859cea8e655a8bbcf36250}

\begin{CompactList}\small\item\em Perform the action of TX antenna button 4 if it was pressed. \item\end{CompactList}\item 
\hypertarget{event__handler_8c_f890f754a450c484ac7e61555f73e472}{
void \hyperlink{event__handler_8c_f890f754a450c484ac7e61555f73e472}{event\_\-aux2\_\-button\_\-pressed} (void)}
\label{event__handler_8c_f890f754a450c484ac7e61555f73e472}

\begin{CompactList}\small\item\em Perform the actions that should be done when AUX 2 button is pressed. \item\end{CompactList}\item 
\hypertarget{event__handler_8c_2a40fb545ab22321ace64dd3ea229ea0}{
void \hyperlink{event__handler_8c_2a40fb545ab22321ace64dd3ea229ea0}{event\_\-sub\_\-button\_\-pressed} (void)}
\label{event__handler_8c_2a40fb545ab22321ace64dd3ea229ea0}

\begin{CompactList}\small\item\em Perform the actions that should be done when the SUB menu button is pressed. \item\end{CompactList}\item 
\hypertarget{event__handler_8c_cd8774b170000657a389c451485b12d2}{
void \hyperlink{event__handler_8c_cd8774b170000657a389c451485b12d2}{event\_\-rxant\_\-button\_\-pressed} (void)}
\label{event__handler_8c_cd8774b170000657a389c451485b12d2}

\begin{CompactList}\small\item\em Perform the action of RX antenna button if it was pressed. \item\end{CompactList}\item 
\hypertarget{event__handler_8c_18c3dccbdf1ce8952d45aca4c06e7fc8}{
void \hyperlink{event__handler_8c_18c3dccbdf1ce8952d45aca4c06e7fc8}{event\_\-rotate\_\-button\_\-pressed} (void)}
\label{event__handler_8c_18c3dccbdf1ce8952d45aca4c06e7fc8}

\begin{CompactList}\small\item\em Perform the action of Rotate button if it was pressed. \item\end{CompactList}\item 
\hypertarget{event__handler_8c_774a4e20c7cf1ae54090699ad3aee5ec}{
void \hyperlink{event__handler_8c_774a4e20c7cf1ae54090699ad3aee5ec}{event\_\-bus\_\-parse\_\-message} (void)}
\label{event__handler_8c_774a4e20c7cf1ae54090699ad3aee5ec}

\begin{CompactList}\small\item\em Parse a message from the communication bus. \item\end{CompactList}\item 
void \hyperlink{event__handler_8c_4f0ca3f469d0211229552dcefebd6084}{event\_\-parse\_\-ext\_\-event} (unsigned int ext\_\-event\_\-status)
\begin{CompactList}\small\item\em Parse an external event and perform the proper action. \item\end{CompactList}\end{CompactItemize}
\subsection*{Variables}
\begin{CompactItemize}
\item 
\hypertarget{event__handler_8c_daf15f291abe7a0a2e653b379d6b3e66}{
x unsigned int \hyperlink{event__handler_8c_daf15f291abe7a0a2e653b379d6b3e66}{main\_\-flags}}
\label{event__handler_8c_daf15f291abe7a0a2e653b379d6b3e66}

\begin{CompactList}\small\item\em Different flags, description is found in main.h. \item\end{CompactList}\item 
\hypertarget{event__handler_8c_1786dd1383f14d64da7639aac32ed3c7}{
unsigned int \hyperlink{event__handler_8c_1786dd1383f14d64da7639aac32ed3c7}{flag\_\-errors} = 0}
\label{event__handler_8c_1786dd1383f14d64da7639aac32ed3c7}

\begin{CompactList}\small\item\em Contains the errors which are set. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
Event handler of various things. 

' \begin{Desc}
\item[Author:]Mikael Larsmark, SM2WMV \end{Desc}
\begin{Desc}
\item[Date:]2010-01-25 

\begin{Code}\begin{verbatim} #include "front_panel/event_handler.c" 
\end{verbatim}
\end{Code}

 \end{Desc}


Definition in file \hyperlink{event__handler_8c-source}{event\_\-handler.c}.

\subsection{Function Documentation}
\hypertarget{event__handler_8c_ae1c682f593e5e0e43093e9bf9391871}{
\index{event\_\-handler.c@{event\_\-handler.c}!event\_\-get\_\-error\_\-state@{event\_\-get\_\-error\_\-state}}
\index{event\_\-get\_\-error\_\-state@{event\_\-get\_\-error\_\-state}!event_handler.c@{event\_\-handler.c}}
\subsubsection[{event\_\-get\_\-error\_\-state}]{\setlength{\rightskip}{0pt plus 5cm}unsigned char event\_\-get\_\-error\_\-state (unsigned char {\em error\_\-type})}}
\label{event__handler_8c_ae1c682f593e5e0e43093e9bf9391871}


Retrieve the state of a specific error type. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em error\_\-type}]Which kind of error we wish to check the state for \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]The current state of this error \end{Desc}


Definition at line 82 of file event\_\-handler.c.

References flag\_\-errors.\hypertarget{event__handler_8c_b842189487606c37f6dfecff12714f6b}{
\index{event\_\-handler.c@{event\_\-handler.c}!event\_\-handler\_\-process\_\-ps2@{event\_\-handler\_\-process\_\-ps2}}
\index{event\_\-handler\_\-process\_\-ps2@{event\_\-handler\_\-process\_\-ps2}!event_handler.c@{event\_\-handler.c}}
\subsubsection[{event\_\-handler\_\-process\_\-ps2}]{\setlength{\rightskip}{0pt plus 5cm}void event\_\-handler\_\-process\_\-ps2 (unsigned char {\em key\_\-code})}}
\label{event__handler_8c_b842189487606c37f6dfecff12714f6b}


Process an PS2 event. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em key\_\-code}]The key that was pressed \end{description}
\end{Desc}


Definition at line 149 of file event\_\-handler.c.

References event\_\-rxant\_\-button\_\-pressed(), event\_\-set\_\-rx\_\-antenna(), event\_\-tx\_\-button1\_\-pressed(), event\_\-tx\_\-button2\_\-pressed(), event\_\-tx\_\-button3\_\-pressed(), event\_\-tx\_\-button4\_\-pressed(), EXT\_\-CTRL\_\-SEL\_\-NONE, EXT\_\-CTRL\_\-SEL\_\-RX\_\-ANT1, EXT\_\-CTRL\_\-SEL\_\-RX\_\-ANT10, EXT\_\-CTRL\_\-TOGGLE\_\-RX\_\-ANT\_\-MODE, EXT\_\-CTRL\_\-TOGGLE\_\-TX\_\-ANT1, EXT\_\-CTRL\_\-TOGGLE\_\-TX\_\-ANT2, EXT\_\-CTRL\_\-TOGGLE\_\-TX\_\-ANT3, EXT\_\-CTRL\_\-TOGGLE\_\-TX\_\-ANT4, ext\_\-key\_\-get\_\-assignment(), KEYPAD\_\-BTN\_\-0, KEYPAD\_\-BTN\_\-1, KEYPAD\_\-BTN\_\-2, KEYPAD\_\-BTN\_\-3, KEYPAD\_\-BTN\_\-4, KEYPAD\_\-BTN\_\-5, KEYPAD\_\-BTN\_\-6, KEYPAD\_\-BTN\_\-7, KEYPAD\_\-BTN\_\-8, KEYPAD\_\-BTN\_\-9, KEYPAD\_\-BTN\_\-A, KEYPAD\_\-BTN\_\-B, KEYPAD\_\-BTN\_\-C, KEYPAD\_\-BTN\_\-D, KEYPAD\_\-BTN\_\-E, KEYPAD\_\-BTN\_\-F, and KEYPAD\_\-BTN\_\-G.

Referenced by event\_\-internal\_\-comm\_\-parse\_\-message().\hypertarget{event__handler_8c_32acf4e703c1e015c422014d22976b9f}{
\index{event\_\-handler.c@{event\_\-handler.c}!event\_\-internal\_\-comm\_\-parse\_\-message@{event\_\-internal\_\-comm\_\-parse\_\-message}}
\index{event\_\-internal\_\-comm\_\-parse\_\-message@{event\_\-internal\_\-comm\_\-parse\_\-message}!event_handler.c@{event\_\-handler.c}}
\subsubsection[{event\_\-internal\_\-comm\_\-parse\_\-message}]{\setlength{\rightskip}{0pt plus 5cm}void event\_\-internal\_\-comm\_\-parse\_\-message ({\bf UC\_\-MESSAGE} {\em message})}}
\label{event__handler_8c_32acf4e703c1e015c422014d22976b9f}


Function which will parse the internal communication message. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em message}]The message that we wish to parse \end{description}
\end{Desc}


Definition at line 91 of file event\_\-handler.c.

References band\_\-ctrl\_\-change\_\-band(), UC\_\-MESSAGE::cmd, computer\_\-interface\_\-is\_\-active(), struct\_\-status::current\_\-display, CURRENT\_\-DISPLAY\_\-SHUTDOWN\_\-VIEW, UC\_\-MESSAGE::data, display\_\-shutdown\_\-view(), event\_\-add\_\-message(), event\_\-handler\_\-process\_\-ps2(), INT\_\-COMM\_\-GET\_\-BAND\_\-BCD\_\-STATUS, INT\_\-COMM\_\-PC\_\-CTRL, INT\_\-COMM\_\-PS2\_\-KEYPRESSED, INT\_\-COMM\_\-TURN\_\-DEVICE\_\-OFF, main\_\-save\_\-settings(), radio\_\-get\_\-current\_\-band(), radio\_\-set\_\-current\_\-band(), remote\_\-control\_\-parse\_\-command(), send\_\-ping(), shutdown\_\-device(), and status.

Referenced by main().\hypertarget{event__handler_8c_4f0ca3f469d0211229552dcefebd6084}{
\index{event\_\-handler.c@{event\_\-handler.c}!event\_\-parse\_\-ext\_\-event@{event\_\-parse\_\-ext\_\-event}}
\index{event\_\-parse\_\-ext\_\-event@{event\_\-parse\_\-ext\_\-event}!event_handler.c@{event\_\-handler.c}}
\subsubsection[{event\_\-parse\_\-ext\_\-event}]{\setlength{\rightskip}{0pt plus 5cm}void event\_\-parse\_\-ext\_\-event (unsigned int {\em ext\_\-event\_\-status})}}
\label{event__handler_8c_4f0ca3f469d0211229552dcefebd6084}


Parse an external event and perform the proper action. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em ext\_\-event\_\-status}]The status of the external \char`\"{}hardware\char`\"{} event flags \end{description}
\end{Desc}


Definition at line 900 of file event\_\-handler.c.

References struct\_\-status::ext\_\-devices\_\-current\_\-state, sequencer\_\-computer\_\-rts\_\-activated(), sequencer\_\-computer\_\-rts\_\-deactivated(), sequencer\_\-footsw\_\-pressed(), sequencer\_\-footsw\_\-released(), sequencer\_\-get\_\-radio\_\-sense(), sequencer\_\-get\_\-rts\_\-polarity(), sequencer\_\-get\_\-sense\_\-polarity(), sequencer\_\-radio\_\-sense\_\-activated(), sequencer\_\-radio\_\-sense\_\-deactivated(), status, STATUS\_\-FOOTSWITCH\_\-BIT, STATUS\_\-RADIO\_\-SENSE1\_\-BIT, STATUS\_\-RADIO\_\-SENSE2\_\-BIT, and STATUS\_\-USB2\_\-RTS\_\-BIT.

Referenced by event\_\-poll\_\-ext\_\-device().\hypertarget{event__handler_8c_632e5b342e5ac553e16febfe66be431d}{
\index{event\_\-handler.c@{event\_\-handler.c}!event\_\-set\_\-error@{event\_\-set\_\-error}}
\index{event\_\-set\_\-error@{event\_\-set\_\-error}!event_handler.c@{event\_\-handler.c}}
\subsubsection[{event\_\-set\_\-error}]{\setlength{\rightskip}{0pt plus 5cm}void event\_\-set\_\-error (unsigned char {\em error\_\-type}, \/  unsigned char {\em state})}}
\label{event__handler_8c_632e5b342e5ac553e16febfe66be431d}


Set that an error has occured. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em error\_\-type}]The type of error that has occured, defines can be found in \hyperlink{errors_8h}{errors.h} \item[{\em state}]State of the error \end{description}
\end{Desc}


Definition at line 65 of file event\_\-handler.c.

References flag\_\-errors, and main\_\-update\_\-ptt\_\-status().

Referenced by bus\_\-resend\_\-message(), internal\_\-comm\_\-resend(), ISR(), menu\_\-action(), rx\_\-queue\_\-add(), and tx\_\-queue\_\-add().\hypertarget{event__handler_8c_a505034c27af0141e92295c18cc89a0f}{
\index{event\_\-handler.c@{event\_\-handler.c}!event\_\-set\_\-rx\_\-antenna@{event\_\-set\_\-rx\_\-antenna}}
\index{event\_\-set\_\-rx\_\-antenna@{event\_\-set\_\-rx\_\-antenna}!event_handler.c@{event\_\-handler.c}}
\subsubsection[{event\_\-set\_\-rx\_\-antenna}]{\setlength{\rightskip}{0pt plus 5cm}void \_\-\_\-inline\_\-\_\- event\_\-set\_\-rx\_\-antenna (unsigned char {\em ant\_\-index})}}
\label{event__handler_8c_a505034c27af0141e92295c18cc89a0f}


Set an RX antenna. Will set the proper flags and call the antenna\_\-ctrl\_\-change\_\-rx\_\-ant function. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em ant\_\-index}]The index of the RX antenna we wish to chose \end{description}
\end{Desc}


Definition at line 140 of file event\_\-handler.c.

References antenna\_\-ctrl\_\-change\_\-rx\_\-ant(), FLAG\_\-UPDATE\_\-DISPLAY, main\_\-flags, struct\_\-status::selected\_\-rx\_\-antenna, and status.

Referenced by event\_\-handler\_\-process\_\-ps2().